/**
 * 
 * 2014-6-11
 */
package com.thinkgem.jeesite.common.pojo.serials.mapper.json;

import com.thinkgem.jeesite.common.pojo.serials.mapper.obj.ObjSerialize;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;


public class JsonSerialize extends ObjSerialize {

	public static void main(String[] args) { 
		JsonSerialize serializeJSON = new JsonSerialize(); 
        serializeJSON.writeJSON(); 
        serializeJSON.readJSON(); 
    } 
 
    public void writeJSON(){ 
        XStream xStream = new XStream(new JettisonMappedXmlDriver()); 
        //Person person = new Person("geniushehe", 16); 
        try { 
            //FileOutputStream fos = new FileOutputStream("E:\\json.js"); 
            xStream.setMode(XStream.NO_REFERENCES); 
            //xStream.alias("Person", Person.class); 
            //xStream.toXML(person, fos); 
        //} catch (FileNotFoundException e) { 
        } catch (Exception e) {
            e.printStackTrace(); 
        } 
    } 
    public void readJSON(){ 
        XStream xStream = new XStream(new JettisonMappedXmlDriver()); 
        //Person person = null; 
        try { 
            //FileInputStream fis = new FileInputStream("E:\\json.js"); 
            xStream.setMode(XStream.NO_REFERENCES); 
            //xStream.alias("Person", Person.class); 
            //person = (Person)xStream.fromXML(fis); 
            //System.out.println(person.getName()); 
            //System.out.println(person.getAge()); 
        //} catch (FileNotFoundException e) {
        } catch (Exception e) {
            e.printStackTrace(); 
        } 
    }

}
